Repository navigation
Reimplement 6 UI::Helpers and UI::MenuItems functions (not yet 100%) - #318
Draft
kotijekriv wants to merge 60 commits into
Draft
kotijekriv wants to merge 60 commits into
kotijekriv wants to merge 60 commits into
Conversation
TrimStoredMenuString stores the string's length into it as an integer (a plain mov, no float conversion), and the scrolling-credits code compares it with an int. The name stays as generated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The header declared int, but the function only leaves the last rand() / 10 in eax; no caller reads it (each of the four call sites overwrites eax right after the call). Declaring it void compiles to the same instructions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It returns the hotspot number or -1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The four siege slots' remaining points sit in one array: SomeSiegeRelatedCopying and SomeSiegeUnitsComputation index it with the slot number. DAT_00b960bc, INT_00b960c0 and INT_00b960c4 were its elements 1 to 3 and go. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It holds one siege setup: 7 units by 3 values, the same shape as one row of DAT_SiegeInformationArray_2 (int[4][7][3]), which it is copied to and from. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s in the unit loops; where the remaining points are loaded UI::Helpers::SomeSiegeUnitsComputation (parameter: the siege slot), rewritten from the binary (gynt's version on his fork's reimpl/UI-MenuItems-development measured 10.6% here). It totals slot 1's remaining points and the value of its siege setup, gives each of the 4 slots its percentage of that total, resets all 4 setups from the template, rescales slot 1 from the chosen slot and the other slots from slot 1, and stores what each slot has left (at least 0). The unit values are a run of 21 ints starting at RenderingDefinedData.ARCHER and the slot percentages 4 ints starting at field1003_0x548dc (the two overlap by one int); INT_00b960b8 is the slots' int[4] (see the header commit). The template copy is one run of 21 values per setup: written as units by values, MSVC keeps a unit loop the original does not have (0.60 vs 0.93 quick_diff). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…places the new-file block before the read path UI::Helpers::WriteMissionToScoresFile (parameters: file name, score), rewritten from the binary (gynt's version on his fork's reimpl/UI-MenuItems-development measured 46.3% here). The scores file is a version (1) followed by the 10 best scores, best first; the version and the scores are one local struct, matching the original's 11-int block. Behaviour fixes against the decompile: a score that does not reach the top 10 returns without writing (the decompile's search never stopped at 10), and a file that cannot be opened for writing returns instead of being written through a null handle. The original lays the new-file block out before the read path; writing the condition as ||, as two ifs, or with the read path in the then-branch all compile to our order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… parameter stores (the 100.0 is read from a shared constant in the original) UI::Helpers::TrimStoredMenuString: the length loop is strlen (MSVC inlines it as the original's loop), stored as an int (see the header commit before this one; the decompile converted it to float, which changes the stored bits). gynt's version on his fork's reimpl/UI-MenuItems-development measured 37.5% here. What is left is which register each parameter store goes through; the order of the statements follows the original's stores. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r level and the result in the same register (eax) UI::Helpers::SomeFearFactorComputation: gynt's version from his fork's reimpl/UI-MenuItems-development (58.3% here) with the comparisons as the asm has them (<= -5, <= -3, <= -1, >= 5) and decimal message numbers. The instructions match; only the register differs: the original reuses eax for the result once the level is no longer needed, ours keeps the level in ecx. A ternary, if/else and early returns all compile to setge instead. The header declares the return type undefined4; it is a message number like its siblings' int. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gister again at the top of each setup; the loop's end address UI::Helpers::ClearSiegeInformationArray2: gynt's version from his fork's reimpl/UI-MenuItems-development (73.9% here) as an index loop over the 4 setups instead of a pointer walking to a raw end address. Like the original it clears only the first 11 of each setup's 21 values. Left: the original sets its zero register again at the top of every setup (ours hoists it), and the loop's end address (the next global there). An intrinsic memset becomes a call instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t other addresses; LARGE_INTEGER is spelled _LARGE_INTEGER on our side UI::Helpers::TicksSinceCounterStart, rewritten from the binary (gynt's version on his fork's reimpl/UI-MenuItems-development measured 59.4% here and returned undefined4 where the header says BOOLEnum). It waits until TIME_QueryMargin ticks have passed, then stores the margin over the elapsed time (both unsigned, which is where the decompile's + 4.2949673e+09 came from) and its inverse. reccmp shows 88.7% because the float constants live at different addresses and LARGE_INTEGER is spelled _LARGE_INTEGER on our side; the instructions match. The flag is compared with TRUE because the original compares it with 1, and the wait stays a do-while because it must read the clock at least once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ddresses carry no symbol (they are FLAG_JokeAIMessageArray[i]) UI::Helpers::PlayJokeVideoBasedOnCurrentTimeAndPlayTime: gynt's version from his fork's reimpl/UI-MenuItems-development (90.6% here). His branch read the joke flags through 13 globals main does not have (FLAG_JokeAIMessage05, INT_00ee236c, ...); they are the elements of main's FLAG_JokeAIMessageArray (0x00EE2350), so the code indexes that array (index = (address - 0x00EE2350) / 4). The 10-second test is written >= 10000 as in the asm, the comma expressions are gone, and the Christmas search is a for loop. reccmp shows 91.3% because the original's flag addresses (0x00EE2354 and so on) carry no symbol while ours resolve to FLAG_JokeAIMessageArray[i]; the addresses and instructions are the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…differs (the same address under another symbol) UI::Helpers::LoadScoresFileToMemory. gynt's version from his fork's reimpl/UI-MenuItems-development. The read loop indexes DAT_MissionScores instead of walking a pointer to a raw end address; only the loop's end address differs from the original (the next global's address there). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…differs (the same address under another symbol) UI::Helpers::PrepareHistoryBook: gynt's version from his fork's reimpl/UI-MenuItems-development (56.4% here) with the particle setup as a plain loop over the 48 entries of INT_ARRAY_00eb0b28 instead of a pointer walking to a raw end address; only the loop's end address differs from the original (the next global's address there). The function returns nothing (see the header commit). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…differs (the same address under another symbol) UI::Helpers::FindCampaignMapHotspotAtMouse: gynt's version from his fork's reimpl/UI-MenuItems-development (70.1% here) as an index loop over the 24 elements of DAT_ARRAY_00ec0348 instead of a pointer walking to a raw end address. The mouse position is read once and the border in each step, as the original does. Only the loop's end address differs (the next global there). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_TextEditor_Buttons stores and tests 0 in pendingTokenTypeToSkip for "no token pending"; the enum had no name for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… .sav/.msv tails not cross-jumped gynt's draft (30.4%) rewritten: the original dispatches with a switch whose save cases come first, copies and extends the file name with the strcpy/strcat intrinsics (the split .tmp/.map/.sav/.msv literals from string-macros.hpp), and calls resolveResourceFileName in every arm, which MSVC cross-jumps. The hand-written security cookie is gone (the compiler adds its own). Left: the .sav/.msv arms are not cross-jumped like the original's, and register allocation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… register allocation gynt's draft (75.0%) with the decompiled loops written as the strlen and strcpy intrinsics (case 4 copies the help section name into ResourceManager's strFileTitle and strFile), and the inner switch's case 0xe writing out the tail it shared with case 4 instead of a goto into it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…llocation gynt's draft (57.7%) with the map file name built by the strcpy/strcat intrinsics (the split .map literal from string-macros.hpp) and without the hand-written security cookie (the compiler adds its own). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… register allocation Scrolling up keeps the offset in a local and stores it once, which gives the original's sub eax, 18 (reading the field into a local and storing iVar4 - 18 gave add eax, -18). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s and do-whiles; registers No gotos or do-whiles left. quick_diff for each form, from 0.6904: - search for a positive siege count, then clear: for + break + index test with the 21 zero stores written out 0.6596; a pointer while 0.6848; for + break + index test with the zeros as a loop 0.8257 (kept) - the second search, leaving the function: indexed for + return 0.8204; pointer for + return 0.8257 (kept, ties the do-while) - the 20-count copy as an indexed for over SEC_SiegeInformation (read as 20 ints): ties the byte-offset do-while - the map description call written in both arms with its constants 0.8918 (kept); with the decompiler's locals 0.8707; the goto to the function's end is a return (ties). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion The two tails Ghidra shared through gotos (the token-advance-and-layout tail, and the token-store tail of cases 11, 12 and 14) are written out at every site with the token named: HTT_INCLUDE and HTT_STRING where the decompiler had ORed two others into 14 and 12. No gotos left. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… gotos as break; shared building-focus goto kept; register allocation Stance cases call queueUnitStance with their own constant instead of jumping to one shared call (0.6719 -> 0.7059 in quick_diff). The engineer and tunneler gotos into the post-switch code became break, which compiles identically. The building-focus check stays one shared block behind a goto: written out in each building case it measures 0.6050, and moving the label to the granary case ties. Number casts to enums replaced by named values (header commits before this one). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…'s != order; register allocation If-chains in the original's layout order (!= tests, else arm last) in the load file-name chain and the load tail; the isHost test without negation, each arm with its whole .msv tail; soundID read inside the arm that uses it, before switchToMenuView; the lordIcon assignment out of the condition, tested as >= 2 as the original does; the player-ID and death-flag store runs as for loops (quick_diff 0.7888 -> 0.9169). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…erMapChoice_MapTable == FALSE as negation; an unused using removed. The generated code does not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 7, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 7, 2026
6and8
pushed a commit
to 6and8/OpenSHC
that referenced
this pull request
Nov 8, 2026
* reimplement: SHC_3BB0A8C1_0x004BBF40 100.0% Reimplemented Moved here unchanged from the draft sourcehold#328 (reimpl/UI-MenuItems-3-development-2, 13fbfea). It was 100% before the header sync a9401a7 and 92.3% on sourcehold#328's base 72b2732, where MSVC stopped sharing the tails of its two number calls. On main 57d3334 it compiles to the original's 100 instructions again, with the shared tail. quick_diff is left with its own artefacts only: the jump-table spelling, the colour immediates, the picture table's address written as its base less 14, and ret / ret 0. reccmp: 99.2% raw and 100% normalized, where only the picture table's address differs (reccmp shows it as an offset into DAT_GMImageHeaders), which the project records as 100%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: MenuItemActionHandler_InGameMenu_Scrolling takes no parameters The original ends with push 1 / call RecordTutorialPlayerAction / pop ecx (0x00434200 to 0x00434207). Declared (int, ...), our function tail-calls through its own argument slot instead (mov [esp + 4], 1 / jmp), which MSVC can only do when the function has a named parameter. Only the menu tables refer to it (six dwords, no call), and like WaitingForHost_ConnectToLobby it never reads an argument. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: SoundEffectID values 254 to 256 as SEID_UNKNOWN_<hex> LobbyMenu_SkirmishTypeAndBalance plays them when the balance changes: 256 at either end (buttons 10 and 14), 255 one step from even (11 and 13) and 254 at even (12); the pushes are at 0x0042A888, 0x0042A8A1 and 0x0042A8B5. The draft wrote them as (SoundEffectID)0x100 and as SEID_UNIT_DAMAGE3 | SEID_PEOPLE_ARE_COMING_TO_THE_CASTLE (248 | 7) and SEID_UNIT_DAMAGE3 | SEID_ARROW_KILL (248 | 6). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x0042A840 100.0% Reimplemented From gynt's fork branch reimpl/UI-MenuItems-100, 97.6% there. On main's headers it compiles to the original's 41 instructions, and quick_diff differs only in its own ret / ret 0. The style pass names the parameter and the button ranges, and the three sound effects by the names the previous commit adds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x004D99F0 100.0% Reimplemented From gynt's fork branch reimpl/UI-MenuItems-100, 97.6% there. Rewritten without the decompiler's gotos, it keeps the original's 85 instructions. quick_diff's differences are its own: ret / ret 0, and the tail jump to MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface at 0x004D9A4F, which our listing writes as jmp trampoline<4603888> (0x00463FF0) and quick_diff does not count as a function. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x00442C30 100.0% Reimplemented Moved from the draft sourcehold#318 (reimpl/batch2-development 49a51e7), 92.6% there. The search for a siege unit now sets a flag and leaves the loop, so its exit jumps past the clearing as the original's does (jg at 0x00442DE3 to 0x00442E64) instead of testing p == end after the loop: quick_diff 0.9753 -> 0.9807. A goto, a flag over the pointer loop and a flag over an index loop all measure the same; the index loop reads best. What is left is quick_diff's own: the security cookie, the timeGetTime import call, ret / ret 0, and the 11 bytes of alignment before the copy loop at 0x00442EA5, which the original's assembler wrote as a jmp over the filler. The style pass replaces the pointer loops with index loops over the 21 counts and returns early for maps that are not sieges. Clean alone build: reccmp 98.9% raw and 100% normalized. The two raw differences are one address, the end of the siege search loops (cmp eax, 0x00B95B1C, one past DAT_SiegeInformationArray), which reccmp resolves to the next global in the original and to our array's end in the DLL; the project records that as 100%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x0047E420 100.0% Reimplemented From gynt's reimpl/UI-MenuItems (PR sourcehold#254, closed), 74.1% there. The label is drawn in two calls with the same colour, one per hover state, and the position goes through two locals computed before them: MSVC then merges the two calls but for the text ID's push (the jne at 0x0047E45D). One call is quick_diff 0.8136, the position inside each arm 0.5479, this form 0.9375, which leaves only the colour immediate and ret / ret 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x00434120 100.0% Reimplemented Moved from the draft sourcehold#327 (reimpl/UI-MenuItems-3-development c1c152b), 89.9% there. With the header taking no parameters (previous commit) the closing RecordTutorialPlayerAction(1) is a call again rather than a tail call: quick_diff 0.9343 -> 0.9710, left with the jump-table spelling and ret / ret 0. The comments now say what -1000 does, and that the frame-rate formula makes up for only part of the slowdown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x00442F40 100.0% Reimplemented From gynt's reimpl/UI-MenuItems (PR sourcehold#254, closed), 77.4% there. The cases now come in the original's order, 1, 2/3, 4, 7, 5, 6, as in LobbyMenu_MapSelectScrollbar on main: the original lays the blocks out in that order (case 7's store at 0x00442FDA sits between case 4 and case 5). quick_diff then differs only in its own jump-table spelling and ret / ret 0. The style pass names the parameters as the LobbyMenu scrollbar does and writes - 13 and ++ / --. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x0047CCA0 100.0% Reimplemented From gynt's reimpl/UI-MenuItems (PR sourcehold#254, closed), 73.6% there, after main's renames (isNameEntryActive). Each case now computes the text's position, fetches the text and draws it itself: MSVC merges the copies of cases 0 to 3 into one tail but for the push of the text's index, as the original has push 5 / push 6 / push 7 / push 0 before its shared tail at 0x0047CDE7; case 4 keeps its own call and the surface reset. With one call after the switch the index goes through a register (quick_diff 0.9365); this form is 0.9664, which leaves the jump-table spelling, the colour immediates and ret / ret 0. The cursor's bottom is written DAT_ButtonY + DAT_ButtonH - 4, the order of the original's lea (0.9030 -> 0.9365 by itself). == TRUE stays: the original compares with 1, and a truthiness test is 0.9365. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: DAT_SH1_SiegeAdvancedMode is a BOOLEnum It was undefined4. Every store is 0 or 1: the toggle xor [0x00B960C8], 1 at 0x0042D81F, 0 at 0x0042D855 (edx, 0 in that handler) and 0x00448DC2 (ebx), 1 at 0x00442E66; the decompilation agrees (SingleplayerMapChoice's MapTable stores 1, ButtonsAndHands toggles it and stores 0, SingleplayerMapChoice_Prepare stores 0), and every read compares with 0 (spawnQueuedReinforcementWaves, LaunchSinglePlayerGameUnk). A linear sweep of the exe's code finds every absolute reference; reads and writes through a pointer to the struct are not covered by that, and the decompilation shows none. Its one user in the code, this PR's MenuItemActionHandler_SingleplayerMapChoice_MapTable (0x00442C30), stores 1 and compiles the same (quick_diff 0.9807 before and after); main has none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: DAT_StoredGameMode is a GameModeInt It was undefined4. Its one store, at 0x004D972A (MenuView_RankingGames_Prepare), copies GameSynchronyState.currentGameMode (0x0191DD80, a GameModeInt), and its one read, in MenuItemActionHandler_RankingGames_Main, copies it back. Both are on main and compile the same; the copy no longer converts between unsigned and int. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: DAT_SkirmishTrailRelated1 is an int It was undefined4. It is a count that can go below 0: MenuView_CrusadeMap_Prepare (0x004D8CB0) stores 3 (0x004D8D48), decrements it once per mission skipped with the chicken and stores the result (0x004D8DD5), then clamps it at 0 with a signed test (cmp edx, edi / jge at 0x004D8DDB); 0x004D8F3B subtracts from it in memory. Main's user, MenuItemRenderFunction_General_CrusadeMapAndEndscreen, tests it with a signed > 0 through an (int) cast, which the next commit drops; it compiles the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: MissionDefinedData.descending is a BOOLEnum It was undefined4. MenuItemActionHandler_RankingGames_Main (0x004D9730) is its only writer: it stores 1 at 0x004D995F when a new column is picked and 1 - descending at 0x004D9970 / 0x004D9976 when the same column is picked again, so it only holds 0 and 1. A linear sweep of the exe's code finds every absolute reference; reads and writes through a pointer to the struct are not covered by that, and the decompilation shows none. The handler is on main and compiles the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: TileMapState.wallDragButtonUp is a BOOLEnum It was undefined4. Its only store, in MenuItemActionHandler_InGameMenu_TriggerPlaceWallCommand at 0x0043803E, writes the result of a sete (0x00438034), so it only holds 0 and 1. A linear sweep of the exe's code finds every absolute reference; reads and writes through a pointer to the struct are not covered by that, and the decompilation shows none. The handler is on main and compiles the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * CrusadeMapAndEndscreen: drop the (int) cast DAT_SkirmishTrailRelated1 no longer needs DAT_SkirmishTrailRelated1 is an int since the commit before this one, so the signed > 0 test needs no cast. It compiles the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * SingleplayerMapChoice_MapTable: store TRUE in DAT_SH1_SiegeAdvancedMode The global is a BOOLEnum since the header commit before this one. Same code (quick_diff 0.9807 before and after). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 9, 2026
General's ToolbarButtonPressed handler (0x00444410) goes from 71.4% here to 100.0% in the round 13 PR (reimpl/UI-B-round13-100, b1710db), with its cases in the original's block order and two Engineer Build fixes this draft needed too: with one catapult or trebuchet and under 10 stone the original only plays the lack-of-stone sound, where this draft queued the command anyway, and after queueing the command the original returns, where this draft also cleared the patrol button and marked an engineer selected. This draft drops its .cpp file, and its status line goes back to main's. Main doesn't have the function, and this draft changes no header, so nothing else goes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6and8
pushed a commit
to 6and8/OpenSHC
that referenced
this pull request
Nov 24, 2026
…cehold#327/sourcehold#328, with one header commit (100%) (sourcehold#410) * headers: MenuModalComposition's slider minimum and maximum are ints sliderMinimum and sliderMaximum were dword. The original treats them as signed: the OverlaySlider handler (0x004AA600) tests `sliderMaximum - sliderMinimum > 200` with jle (0x4aa630, 0x4aa697, 0x4aa7a3) and divides by 5 signed (0x4aa635, 0x4aa6c4). With the fields as int the handler measures 100.0 instead of 57.1 (reccmp, main 1d819b7; the same again on 3416498). The only other users of the two fields, setSliderParameters and setSliderParameters2, only store to them, so they compile the same. sliderValue stays dword: the original only copies it, and the handler compiles to the same code either way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x004AA600 100.0% Reimplemented MenuItemActionHandler_OverlaySlider_Slider, from our own drafts at 89.8% and 91.5% (local, never pushed), themselves rewritten from gynt's draft (593c4ef at 47.37% on his fork's reimpl/UI-MenuItems-development; his last style pass on the file is f6c6b8b). It needs the slider minimum and maximum as ints (the MenuModalComposition header commit before this one); with them reccmp reads 100.0, normalised 100.0. The fix: case 1 stores the current value once, after the large-range and small-range branches, rather than at the end of each. MSVC then gives the small-range branch the original's scratch registers, and case 2 and 3 follow (the store in each branch measured 91.5). Case 7 tests `*currentValue > *maxValue / 2` for the step of 1, which gives the original's setle. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x004255D0 100.0% Reimplemented MenuItemRenderFunction_HistoricCampaignSelect_Main, from the draft sourcehold#327 (reimpl/UI-MenuItems-3-development, 90d1284 at 98.7%; the file's newest commit on the draft is 446f9fa), itself rewritten from gynt's draft (d07873b at 97.44%, after his 61351fe at 82.1% and 245178b at 94.87%; on his fork's reimpl/UI-MenuItems-development the function is 04f12f8 at 67.10%, his newest reimplement commit on the file is 8725ec5 and his last style pass 5084980). reccmp 100.0, quick_diff 78/78 at 1.0000. The last difference was the getTextStringInGroupAtOffset call loading ecx after both its pushes, where the original loads it between them. The campaign name is drawn by two calls that are the same, one per hover state, each with the position read into `int const textY` then `textX`: MSVC merges them completely and keeps the original's order. It is the same form as in MainMenu's render (0x00424F50), the sibling this function was copied from. The early returns, the branch order, the sound ID SEID_UNKNOWN_0x92 and the campaign names from cr.tex were already in the draft. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x00492FD0 100.0% Reimplemented MenuItemRenderFunction_SaveLoadMap_TableHeader, from gynt's draft (78de101 at 97.44% on his fork's reimpl/UI-MenuItems, after his 0747a3c; on his reimpl/UI-MenuItems-development the file has 2002473, and his newest reimplement commit on it there is 8725ec5; quick_diff 0.9744 on main). reccmp 100.0, quick_diff 39/39 at 1.0000. The draft's only difference was the getTextStringInGroupAtOffset call loading ecx after both its pushes, where the original loads it between them. As in HistoricCampaignSelect's render (0x004255D0, earlier on this branch), the header text is written as two calls that are the same, one per hover state, each with `int const textY` then `textX`: MSVC merges them completely, leaving no branch, and keeps the original's order. Position locals alone measured the same as the draft. The column switch and its text numbers were already gynt's ("Name", "Date" and "Mission" in TEXT_GAME_OPTIONS); the colour is COL_CCFAFF, the font size 18, and the parameter is the column. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x004D8EC0 100.0% Reimplemented MenuItemActionHandler_CrusadeMap_Main, rewritten from the binary. It starts from gynt's draft (00e21e3, 59034df and 98dc115 on his fork's reimpl/UI-MenuItems, 33.48% there; 3d6fb54 at 34.80% on his reimpl/UI-MenuItems-development, his newest reimplement commit on the file) and our mechanical pass of it in sourcehold#328 (2d468df, 35.2%). reccmp 100.0 (normalized 100.0), quick_diff 215/215 at 0.9907, the rest being the timeGetTime import call, which reccmp resolves. The buttons are Skip Current Mission (1000), the lord's face for the mission briefing (10), back to the choice of crusade (11), a click on the map (1) and the rankings (99), in the original's block order with early returns. What the match needed: - Skip Current Mission repeats the setStartDateUnk call and everything after it in each trail's branch. MSVC merges the three copies into the first one, as the original has them, and the constant 1 then goes to ebp; one call after the trail branches, or a switch on the trail type, measured 0.9395 and 0.8419. - The click test reads each position as `left = x - 10` and `top = y - 10`, compared with `left + 20` and `top + 20`, which is how the original computes both bounds (0.6075 with x - 10 and x + 10). Fixes against the draft: - The first edition and extreme trails tested the click's y the wrong way round (Ghidra's `y + -clickY >= 10`, that is clickY <= y - 10, where the original tests clickY >= y - 10), so a mission could only be picked by clicking above it. - The warchest and extreme searches went one mission too far (`> 30` and `20 <`), reading one position past the end of the warchest table; the original stops below 30 and 20. Cleanup: a click wrote all three trails' progress back, two of them unchanged; the original stores only the trail being played. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x00444410 100.0% Reimplemented MenuItemActionHandler_General_ToolbarButtonPressed, from gynt's draft (d2993ae, 6e17808, 8a21939 and b984b98 on his fork's reimpl/UI-MenuItems, 65.02% there; a1c4156 at 67.59% and 9dc4216 at 67.74% on his reimpl/UI-MenuItems-development, 9dc4216 being his newest reimplement commit on the file) and our own draft in sourcehold#318 (c00f64a at 71.40% on reimpl/batch2-development), rearranged from the binary. The function leaves sourcehold#318 with this commit. reccmp 100.0 (normalized 100.0). quick_diff reads 0.8939 because it stops the original after the siege-engine case. On main the draft needed only renames to compile: buildingEntryInfos for the eight building references, unitIDSelectedCatapultOrTrebuchet and field_0x30. What the match needed: - The switch cases in the original's block order. The siege engines (with the Arab ballista) and the tunnel are plain cases that break to the code after the switch, and the three stances each make their own call (quick_diff 0.6693 -> 0.7085). - The eight building buttons each move the view to their building in their own copy of that code. MSVC merges the copies into the granary's, where the original has them, followed by the code after the switch (0.7085 -> 0.8915); one shared label puts the block after the last of them instead: reccmp 75.2 (normalized 61.3) against 100.0. - The tunnel button tests for no tunneler first. Fixes against the draft: - With one catapult or trebuchet selected and under 10 stone, the original only plays the lack-of-stone sound; the draft queued the command anyway. - After queueing the command for one engine or for the selection, the original returns; the draft went on to clear the patrol button and mark an engineer as selected. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Gynt <gynt@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Six functions, so others can continue from them (gynt's rule: ready functions in their own PR, the rest in a draft):
This is the draft half of this batch (9 files); the ready half, #319, is merged. TrimStoredMenuString and WriteMissionToScoresFile reached 100% and moved to the ready #332. Both continue gynt's drafts on his fork (
reimpl/UI-MenuItems-development). Five more Helpers functions started here (FindCampaignMapHotspotAtMouse, LoadScoresFileToMemory, PlayJokeVideoBasedOnCurrentTimeAndPlayTime, PrepareHistoryBook, TicksSinceCounterStart) and are at 100% in #323.Built on top of
main(ed469ea, since merged with main up to 72b2732 and its header syncs) with the bundled MSVC1400-SP1, natively on Windows, against the SteamStronghold Crusader.exe(3bb0a8c1…5387ac5a). The branch was built and measured on its own (every reimplemented.cppit contains), with the struct and function resolvers enabled locally (not committed), using sourcehold's reccmp with--resolve-wrapped-calls --ignore-security-cookie. None of it has been run in game.Every function matches its status line. The mechanical style points from the reviews of #311 and #312 are applied; the drafts from gynt's branch still have some decompiler names in places.
No header change left: main's Ghidra sync a9401a7 named -1
UT_INVALID(and 0UT_NONE), so the patrol button in ToolbarButtonPressed now compares getUnitTypeOfFirstSelectedUnit's result withUT_INVALID. Main 72b2732 is merged in, with the sync's other new names used.Main's Ghidra syncs took every other header change this PR proposed:
INT_00eb9b24(wasFLOAT_00eb9b24) as anint, PrepareHistoryBook'svoid,HTT_NONE,GCT_UNKNOWN_86,SEID_UNKNOWN_0x87andBT_NONE, and before thatINT_ARRAY_00b960b8andDAT_SiegeInformationArray.MenuItemActionHandler_General_ToolbarButtonPressedClearSiegeInformationArray2SomeFearFactorComputationSomeSiegeUnitsComputationMenuItemActionHandler_ProgressBarBox_LoadAndSaveGameButtonLogicMenuItemActionHandler_TextEditor_ButtonsBehaviour fixed compared with the drafts
🤖 Generated with Claude Code